#ifndef MAINVIEW_H
#define MAINVIEW_H

#include "Guy.h"
#include "OldGuy.h"
#include "Bullet.h"
#include "ComeToScene.h"
#include "GuyDeath.h"
#include <QRandomGenerator>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QFileInfo>
#include <QIcon>
#include "background.h"
#include "smallenemy.h"
#include <QTimer>
#include <QDebug>
#include"followsmallenemy.h"
#include"totalcontrol.h"
#include"BulletTouchThread.h"
#include<QThread>
#include"mantouchthread.h"
class MainView : public QGraphicsView
{
    Q_OBJECT
public:
    MainView();
    SmallEnemy *smallEnemy1;
    FollowSmallEnemy *followSmallEnemy1;

    void keyPressEvent(QKeyEvent* event);
    void keyReleaseEvent(QKeyEvent* event);
    void mouseReleaseEvent(QMouseEvent *event);
    void mousePressEvent(QMouseEvent *event);
    void Shooting();
    void mouseMoveEvent(QMouseEvent *event);
    void updateGuyPos();
    void guyComeToScenePos();
    void updateOldGuy();
    void RestartGame(int t);

private:
    QPixmap aim;

    QGraphicsPixmapItem *gameovertip;
    QGraphicsPixmapItem *gamethrough;

    QTimer *totalTimer;
    QTimer *CTSTimer;
    QTimer *guyDeathTimer;
    QTimer *oldguyDeathTimer;

    QGraphicsScene *scene;
    BackGround *bg;
    QString root;
    Guy *guy;
    ComeToScene *cts;
    GuyDeath *guydeath;

    QList<OldGuy*> oldguylist;
    QList<Bullet*> allbulletlist;
    QList<QList<QPointF*>> oldguyposlist;
    QList<QList<double>> oldguyrotatelist;
    QList<QList<int>> oldguyshootlist;

    TotalControl *contralor;//控制器

    float Keyx;
    float Keyy;
    float x;
    float y;//鼠标坐标
    QLineF *qline;
    double rotate;
    int MoveSign;//表示移动状态
    //int EnemyBulletShoot;
    int shootsignal;


    QThread *thread;
    BulletTouch *bulletTouch;
    
    QThread *thread2;
    ManTouchThread *manTouch;

    int rotatetime;
    int guydeathtime;
    int index;
    int isPlaying; //游戏是否进行中1
    int ShouldCallEnemy;


signals:
    void wStart();//信号函数，传入信号
    void meStart();
public slots:
    //void TouchTh(QList<Bullet*> bul,QList<SmallEnemy*> smal);//槽函数
    void TotalTimer();





    void ComeToSceneAniTimer();
    void GuyDeathAniTimer();
    void oldGuyDeathAniTimer();

};


#endif // MAINVIEW_H
